<?php
/**
 * Created by PhpStorm.
 * User: Frings
 * Date: 2016/9/9
 * Time: 16:37
 */


use yii\helpers\Url;

$web = Url::base();
?>

<script>
    function exportVoucher() {
        var data = {};
        data.start_index = '<?=$start_index?>';
        data.end_index = '<?=$end_index?>';
        var result = requestJson("export-voucher-handler", data);
        if (result.status == 0) {
            var url = "<?= $web ?>/" + result.data;
            window.open(url);
        } else {
            alert(result.message);
        }
    }
</script>

<div class="form-group">
    <button class="btn btn-link btn-xs" type="button"
            onclick="exportVoucher()">导出
    </button>
</div>

<table class="table table-bordered table-hover table-condensed">
    <thead class="nowrap">
    <tr>
        <th>单证号</th>
        <th>状态</th>
        <th>昵称</th>
        <th>手机号</th>
        <th>使用时间</th>
    </tr>
    </thead>
    <tbody>
    <?php
    if ($list != null && count($list) > 0) {
        for ($i = 0; $i < count($list); $i++) {
            ?>
            <tr>
                <td><?= $list[$i]['voucher'] ?></td>
                <td>
                    <?php
                    switch ($list[$i]['status']) {
                        case 0:
                            echo '<label class="label label-default">未使用</label>';
                            break;
                        case 1:
                        case 6:
                            echo '<label class="label label-info">已绑定</label>';
                            break;
                        case 2:
                            echo '<label class="label label-success">已激活</label>';
                            break;
                        case 3:
                            echo '<label class="label label-danger">已使用</label>';
                            break;
                        case 4:
                            echo '<label class="label label-warning">失效</label>';
                            break;
                        case 5:
                            echo '<label class="label label-warning">过期</label>';
                            break;
                    }
                    ?>
                </td>
                <td>
                    <?= $list[$i]['name'] ?>
                </td>
                <td>
                    <?= $list[$i]['phone'] ?>
                </td>
                <td>
                    <?= $list[$i]['create_datetime'] ?>
                </td>
            </tr>
            <?php
        }
    }
    ?>
    </tbody>
</table>
